//- Copyright (c) 2016 Lucky Byte, Inc.
extends ../table

block form_items
  .field.thirteen.wide
    .ui.buttons.right.floated.small.compact
      button.ui.green.button.labeled.icon(type="submit") 查 询
        i.icon.search
      button.ui.blue.button(type="button"
        onclick="window.location = '/t40_recvr/done'") 追付历史

block thead
  tr
    th.center.aligned(rowspan="2") 序号
    th.center.aligned(rowspan="2") 产 品
    th.center.aligned(colspan="5") 原始交易
    th.center.aligned(colspan="5") 代付交易
    th(rowspan="2")
  tr
    th.center.aligned 交易时间
    th.center.aligned 商户编号
    th.center.aligned 终端编号
    th.center.aligned 交易金额
    th.center.aligned 跟踪号
    th.center.aligned 代付商户
    th.center.aligned 订单号
    th.center.aligned 代付金额
    th.center.aligned 确认
    th.center.aligned 备 注

block tbody
  each record in records
    tr(class="#{record.inputed ? 'positive' : ''}")
      td.center.aligned.collapsing= record.serial
      td.center.aligned.collapsing
        if record.product == 'p1'
          | 消费代付
        else if record.product == 'p2'
          | 助农取款
        else
          | 未知
      td.center.aligned.collapsing= record.tr1_systime.format('MM-DD HH:mm:ss')
      td.center.aligned.collapsing= record.tr1_info[0]
      td.center.aligned.collapsing= record.tr1_info[1]
      td.center.aligned.collapsing= fmtamt2(record.tr1_info[2])
      td.center.aligned.collapsing= record.tr1_info[3]

      if record.tr2_info
        td.center.aligned.collapsing= record.tr2_info[0]
        td.center.aligned.collapsing= record.tr2_info[1]
        td.center.aligned.collapsing= fmtamt2(record.tr2_info[2])
        td.center.aligned.collapsing
          if record.tr2_confirm
            i.icon.checkmark
        td.center.aligned= record.tr2_notes
      else
        td.center.aligned.collapsing(colspan="5") 无代付交易

      if record.inputed
        if page_perms.check && record.inputer != userinfo.uuid
          td.center.aligned.collapsing
            i.icon.checkmark.box.blue.link(
              data-content="确认此追付" data-variation="small"
              onclick="window.location = '/t40_recvr/check/#{record.uuid}'")
        else
          td.center.aligned.collapsing
            i.icon.wait.orange.link(
              data-content="已追付，等待复核" data-variation="small")
      else
        if page_perms.new
          td.center.aligned.collapsing
            i.icon.arrow.right.link.green(
              data-content="开始追付" data-variation="small"
              onclick="window.location = '/t40_recvr/new/#{record.uuid}'")
        else
          td.center.aligned.collapsing
            i.icon.ban.grey(
              data-content="权限拒绝" data-variation="small")
  else
    td.center.aligned.warning(colspan="13") 无数据
